<?php
/**
 * Created by PhpStorm.
 * User: zhao shou qiang
 * Date: 2017/12/27 0027
 * Time: 14:46
 */


use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\widgets\ActiveForm;

$host = Yii::$app->request->hostInfo;
$category = Yii::$app->params['InvestigationFileCategory'];

?>

<style type="text/css">
    .txt-cut {
        width: 60px !important;
        height: 45px !important;
        overflow: hidden;
        text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用*/
        display: -webkit-box;
        /*//显示两行*/
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        /*/制换行,支持文字和紫门  会把单词截断掉的*/
        word-break: break-all;
        /* 不会把单词截断掉的。*/
        word-wrap: break-word;
        font-family: 'Microsoft YaHei', Tahoma, Arial, sans-serif;
    }

    #myModal .modal-content .modal-body .fileBox .upload_img_click .uploadImg {
        padding: 26px 0 0 14px;
    }

    .jinTiao91 form table tr th:nth-child(8), .jinTiao91 form table tr td:nth-child(8) {
        width: 18%;
    }

    .pagingBox, .pagination {
        margin-top: 0px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    .pagination {
        top: 20px
    }

    .pageBox {
        position: absolute;
        top: 26px;
        right: 0px;
    }

    .totalSize {
        font-size: 16px;
        padding-right: 16px;
    }

    #fuJian .container {
        padding-bottom: 80px;
    }

    .jinTiao91 .pull-right span {
        padding-right: 12px;
        text-indent: 26px;
        width: auto;
        cursor: pointer;
    }

    .uploaded_by {
        text-align: center;
    }
</style>

<div class="jinTiao91 top10" id="fuJian">
    <div class="container containerShadow">
        <div class="row">
            <div class="topimg">
                <div class="left pull-left">
                    <span>关键附件</span>
                </div>
                <div class="pull-right">
                    <!--<a href="###">
						<img class="editImg" src="image/projectDetails/edit.png" >
						</a>-->
                </div>
            </div>
            <div class="nearbyTop clearfix">
                <div class="pull-left">
                    <span class="onOff" title="红旗开关"></span>
                    <span>只显示红旗附件</span>
                    <select name="category" class="category_list">
                        <option value="0" selected>请选择</option>
                        <?php
                        if (!empty($category) && is_array($category)) {
                            foreach ($category as $key => $value) {
                                echo '<option value="' . $key . '">' . $value . '</option>';
                            }
                        }
                        ?>
                    </select>
                </div>
                <div class="pull-right">
                    <span class="jinTiao91Active upload-file" data-toggle="modal" data-target="#myModal">上传附件</span>
                    <span onclick="downloads()">批量下载</span>
                    <span onclick="searchHistory()">查找关联历史档案</span>
                </div>
            </div>

            <div class="img_list">
                <?php if (is_array($list) && !empty($list)) { ?>
                    <form action="" method="post" class="file_list">
                        <table border="" cellspacing="" cellpadding="">
                            <tr class="tableTop page_list_prev">
                                <th>
                                    <input type="checkbox" class="whole"/>
                                </th>
                                <th>序号</th>
                                <th>文件名称</th>
                                <th>附件内容</th>
                                <th>文件大小</th>
                                <th>上传人</th>
                                <th>上传时间</th>
                                <th width="20%">操作</th>
                            </tr>
                            <?php
                            $i = 1;
                            if (is_array($list) && !empty($list)) {
                                foreach ($list as $key => $value) {
                                    $html = '<tr data-id="' . $value['id'] . '">
                                    <td>
                                        <input type="checkbox" name="" id="' . $value['id'] . '" value="'. $value['id'] .'"/>
                                    </td>
                                    <td>' . $i++ . '</td>
                                    <td>';
                                        if ($value['state'] == 1) {
                                            $html .= '<span class="redFlag " data-id="' . $value['id'] . '" title="单击改变红旗"></span> ';
                                        } else {
                                            $html .= '<span class="redFlag redFlag2" data-id="' . $value['id'] . '" title="单击改变红旗"></span> ';
                                        }
                                        $html .= '<span class="tableSpan" title="' . $value['title'] . '">
                                            <input type="text" class="table-text" data-title="' . $value['title'] . '" readonly="readonly" value="' . $value['title'] . '"/>
                                        </span>
                                    </td>
                                    <td class="selectBox" style="text-align:center; vertical-align:middle;">
                                        <select name="category" class="select-sanjiao category" id="table-select" disabled="disabled">';

                                        $fileCategory = $category;
                                        if ($value['category'] > 0) {
                                            foreach ($fileCategory as $k => $v) {
                                                if ($value['category'] == $k) {
                                                    $html .= '<option value="' . $k . '" selected>' . $v . '</option>';
                                                } else {
                                                    $html .= '<option value="' . $k . '" >' . $v . '</option>';
                                                }
                                            }
                                        } else {
                                            $html .= '<option value="0" selected>全部</option>';
                                        }

                                        $html .= '</select>
                                    </td>
                                    <td>
                                        <span>' . $value['size'] . '</span>
                                    </td>
                                    <td  class="uploaded_by">
                                        <input type="text" readonly value="' . $value['uploaded_by'] . '"/>
                                    </td>
                                    <td>
                                        <input type="text" style="text-align: center;" readonly value="' . $value['created_at'] . '"/>
                                    </td>
                                    <td>
                                        <span>
                                        <a href="' . Url::toRoute(['project-investigation-file/download', 'id' => $value['id'], 'project_id' => $value['project_id']]) . '"> 
                                            <img  src="' . $host . '/image/projectDetails/download.png" alt="下载" title="下载" data-url="' . Url::toRoute('project-investigation-file/download', true) . '" data-id="' . $value['id'] . '"/>
                                        </a>
                                        </span >
                                        <span >
                                            <img class="delete_file" src="' . $host . '/image/projectDetails/recovery.png" class="remove" alt="删除" title="删除" 
                                             data-url="' . Url::toRoute('project-investigation-file/delete', true) . '" data-id="' . $value['id'] . '"/>
                                        </span>
                                        <span>
                                        <a href="/uploads/investigation-file/' . $value['file_name'] . '"  target="_blank">
                                            <img  src="' . $host . '/image/projectDetails/eye.png" class="show_image" data-src="' . $value['file_name'] . '" alt="查看" title="查看" />
                                        </a>
                                        </span>
                                        <span>
                                        <img  src="' . $host . '/image/projectDetails/tableEdit.png" class="tableEdit edit-tab"
                                        alt="编辑" title="编辑" />
                                        </span>
                                    </td>
                                </tr>';
                                    echo $html;
                                }
                            } ?>
                        </table>
                    </form>
                    <!--//分页部分开始-->
                    <div class="box-body pagingBox container">
                        <div class="row">
                            <div class="page" id="page_list">
                                <?php echo $linkPager; ?>
                            </div>

                            <div class="pageBox">
                                <div class="">
                                    <!--<span class="pageT pageTotal"></span> 每页
                                    <a id="list">
                                       <span class="number">10</span>
                                        <ul class="pageTotalBox">
                                            <li class="pageNum">5</li>
                                            <li class="pageNum pageActive">10</li>
                                            <li class="pageNum">20</li>
                                            <li class="pageNum">30</li>
                                            <li class="pageNum">40</li>
                                         </ul>
                                        <b class="caret"> </b>
                                    </a>
                                    行-->
                                    <span>
								共<span class="totalSize"><?php echo $count; ?></span>条记录
		                     </span>
                                </div>
                            </div>
                        </div>
                    </div>

                <?php } else { ?>
                    <form action="" method="post" class="file_list">
                        <table border="" cellspacing="" cellpadding="">
                            <tr class="tableTop page_list_prev">
                                <th>
                                    <input type="checkbox" class="whole"/>
                                </th>
                                <th>序号</th>
                                <th>文件名称</th>
                                <th>附件内容</th>
                                <th>文件大小</th>
                                <th>上传人</th>
                                <th>上传时间</th>
                                <th width="20%">操作</th>
                            </tr>
                            <tr>
                                <td colspan="8" style="text-align:center; margin:0 auto;padding: 20px;">
                                    <?php echo Html::img('@web/image/defaultPage/nothing.png', ['style' => 'display:inline-block;width:100%']); ?>
                                </td>
                            </tr>
                        </table>
                    </form>
                <?php } ?>

            </div>
        </div>
    </div>

    <!-- 上传模态框开始（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="false">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header clearfix">
                    <div class="pull-left">
                        <?php echo Html::img('@web/image/officeHall/uploadAssetPackage/mask.png', ['class' => 'pull-left maskImg']); ?>
                        <span class="pull-left uploadText">上传附件</span>
                    </div>
                    <?php echo Html::img('@web/image/officeHall/uploadAssetPackage/clos.png',
                        ['class' => 'pull-right uploadImg', 'data-dismiss' => 'modal', 'aria-hidden' => 'true', 'tilte' => '单击关闭遮罩层', 'style' => 'margin-top: 10px; cursor:pointer;']); ?>
                </div>
                <div class="modal-body">
                    <p>1.所属模块</p>
                    <div class="selectBox">
                        <select name="category" id="category_upload">
                            <option value="0" selected>请选择</option>
                            <?php
                            if (!empty($category) && is_array($category)) {
                                foreach ($category as $key => $value) {
                                    echo '<option value="' . $key . '">' . $value . '</option>';
                                }
                            }
                            ?>
                        </select>
                    </div>
                    <p>2.请选择本地文件上传</p>
                    <div class="fileBox">
                        <ul class="clearfix">
                            <li class="upload_img_click">
                                <?php echo Html::img('@web/image/officeHall/uploadAssetPackage/upLoadListBtnTwo.png', ['class' => 'uploadImg', 'title' => '单击继续添加']); ?>
                                <form enctype="multipart/form-data" class="uploads" style="display: none;">
                                    <div class="form-group">
                                        <div class="file-loading">
                                            <!--<input id="file-1" name="UploadImgForm[imageFiles][]" type="file"  accept="image/*"
                                                   class="file" multiple data-overwrite-initial="true">-->

                                            <input id="uplaodImages" name="UploadImgForm[imageFiles][]" type="file"
                                                   accept="image/*" class="file" multiple>
                                        </div>
                                    </div>
                                </form>
                                <input type="hidden" id="files_name" value=""/>

                                <input type="hidden" id="upload_url"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/upload', true) ?>"/>

                                <input type="hidden" id="file_delete_url"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/delete-file', true) ?>"/>

                                <input type="hidden" id="file_delete"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/delete', true) ?>"/>

                                <input type="hidden" id="file_update"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/edit', true) ?>"/>

                                <input type="hidden" id="file_get_list"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/ajax-list', true) ?>"/>

                                <input type="hidden" id="file_download"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/download', true) ?>"/>

                                <input type="hidden" id="file_downloads"
                                       value="<?php echo \yii\helpers\Url::toRoute('project-investigation-file/download-zip', true) ?>"/>

                                <input type="hidden" id="current_page" value="<?php echo $page; ?>">
                            </li>
                        </ul>
                        <p class="errorText"></p>
                        <p>
                            1.支持批量上传;<br/>
                            2.文件大小不能超过30M。
                        </p>
                    </div>
                </div>
                <div class="modal-footer">
                    <div class="uploadyn">
                        <input id='cancel' class="active" data-dismiss="modal" aria-hidden="true" type="button" value="确定"/>
                        <input id="confirm" type="button" data-dismiss="modal" aria-hidden="true" value="取消"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--上传模态框结束-->
    